package com.ruoyi.manager.service.impl;

import java.util.List;

import com.basic.service.impl.BaseServiceImpl;
import com.ruoyi.manager.domain.MgServiceManager;
import com.ruoyi.manager.mapper.MgServiceManagerMapper;
import com.ruoyi.manager.service.IMgServiceManagerService;
import org.springframework.stereotype.Service;

/**
 * 服务管理Service业务层处理
 * 
 * @author ruoyi
 * @date 2023-12-13
 */
@Service
public class MgServiceManagerServiceImpl extends BaseServiceImpl<Long, MgServiceManager> implements IMgServiceManagerService 
{
    public MgServiceManagerServiceImpl(MgServiceManagerMapper baseMapper) {
		super(baseMapper);
		// TODO Auto-generated constructor stub
	}


    /**
     * 查询服务管理
     * 
     * @param id 服务管理主键
     * @return 服务管理
     */
    @Override
    public MgServiceManager selectMgServiceManagerById(Integer id)
    {
        return this.baseMapper.selectById(id);
    }

    
    /**
     * 查询服务管理列表
     * 
     * @param mgServiceManager 服务管理
     * @return 服务管理
     */
    @Override
    public List<MgServiceManager> selectMgServiceManagerList(MgServiceManager mgServiceManager, String picPrefix)
    {
        List<MgServiceManager> selectMgServiceManagerList = this.baseMapper.selectList(mgServiceManager);
        
        for (MgServiceManager manager : selectMgServiceManagerList) {
			
        	manager.setPic("https://".concat(picPrefix.concat(manager.getPic())));
		}
        
		return selectMgServiceManagerList;
    }

    /**
     * 新增服务管理
     * 
     * @param mgServiceManager 服务管理
     * @return 结果
     */
    @Override
    public int insertMgServiceManager(MgServiceManager mgServiceManager, String picPrefix)
    {
    	String pic = mgServiceManager.getPic();
    	
    	pic = pic.replaceAll("https", "").replaceAll("http", "").replaceAll(picPrefix, "");
    	
    	insertProperties(mgServiceManager);
    	
    	mgServiceManager.setPic(pic);
    	
        return this.baseMapper.insert(mgServiceManager);
    }

    /**
     * 修改服务管理
     * https://keteng-ps.oss-cn-hangzhou.aliyuncs.com
     * http://keteng-ps.oss-cn-hangzhou.aliyuncs.com/news/20231221/computerFwgO2.png
     * @param mgServiceManager 服务管理
     * @return 结果
     */
    @Override
    public int updateMgServiceManager(MgServiceManager mgServiceManager, String picPrefix)
    {
    	String pic = mgServiceManager.getPic();
    	
    	pic = pic.replaceAll("https://", "").replaceAll("http://", "").replaceAll(picPrefix, "");
    	
    	updateProperties(mgServiceManager);
    	
    	mgServiceManager.setPic(pic);
    	
        return this.baseMapper.update(mgServiceManager);
    }

    /**
     * 批量删除服务管理
     * 
     * @param ids 需要删除的服务管理主键
     * @return 结果
     */
    @Override
    public int deleteMgServiceManagerByIds(Integer[] ids)
    {
        return this.baseMapper.deleteByIds(ids);
    }

    @Override
	public List<MgServiceManager> selectListByIds(int[] ids) {
		// TODO Auto-generated method stub
		return super.selectListByIds(ids);
	}


	/**
     * 删除服务管理信息
     * 
     * @param id 服务管理主键
     * @return 结果
     */
    @Override
    public int deleteMgServiceManagerById(Integer id)
    {
        return this.baseMapper.deleteById(id);
    }


	@Override
	public List<MgServiceManager> selectMgServiceManagerList(MgServiceManager mgServiceManager) {
		// TODO Auto-generated method stub
		return this.baseMapper.selectList(mgServiceManager);
	}
}
